package com.zzld.modules.maintenance.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.github.abel533.entity.Example;
import com.zzld.core.service.BaseServiceImpl;
import com.zzld.modules.common.dto.TreeGrid;
import com.zzld.modules.maintenance.entity.Brand;
import com.zzld.modules.maintenance.mapper.BrandMapper;
import com.zzld.modules.maintenance.service.IBrandService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BrandServiceImpl extends BaseServiceImpl<Brand> implements
		IBrandService {
	@Autowired
	private BrandMapper brandMapper;

	private static final Logger logger = LoggerFactory
			.getLogger(BrandServiceImpl.class);

	@Override
	public List<TreeGrid> treegrid() {
		// TODO 自动生成的方法存根
		List<TreeGrid> treeGrids = new ArrayList<TreeGrid>();
		List<Brand> list = new ArrayList<Brand>();
		Example example = new Example(Brand.class);
		list = brandMapper.selectByExample(example);
		if (list.size() > 0) {
			for (Brand b : list) {
				TreeGrid grid = new TreeGrid();
				BeanUtils.copyProperties(b, grid);
			    grid.setId(b.getBrandId());
			    grid.setPid(b.getPid());
				grid.setText(b.getBrandname());
				grid.setCreateDate(b.getInnertime());
				treeGrids.add(grid);
				}
		}
		return treeGrids;
	}
}